import pymongo


class MongoDao(object):

    def __init__(self, collection_name):
        self.mongo_connect = pymongo.MongoClient(host="127.0.0.1", port=27017)
        self.nickname_db = self.mongo_connect['db_nickname']
        self.collection = self.nickname_db[collection_name]

    def insert(self, entity):
        inserted_id = self.collection.insert_one(entity).inserted_id
        print("Name:[%s] --->[%s] inserted!" % (entity['name'], inserted_id))
